<?php
//This output goes into #right_nav_container_ajax div tag of default.ctp
echo $form->create(null, array('url' => '/waiters/ajxOrder'));
if (isset($output) && is_array($output)) {
    e("<table border=1>");
    //debug($output);
    $total = 0.00;
    foreach ($output as $menu_item_id => $detailsArray) {
        //$detailsArray data structure is defined in  writingpad_controller
        $name = $detailsArray["from_writingpad_menu_item_name"];
        $qty = $detailsArray["from_writingpad_quantity"];
        $price = $detailsArray["from_writingpad_price"];
        $total = $total + ($qty * $price);
        e("<tr>");
        e("<td>" . $name . "</td>" . "<td>" . $qty . "</td>" . "<td>$" . $price . "</td>");
        e("</tr>");
    }
    e("<tr>");
    e("<td colspan=2>" . "Total" . "</td>" . "<td>$" . $total . "</td>");
    e("</tr>");
    e("</table>");

    $linkMetaData = array(
        "controller" => "orders",
        "action" => "add"
    );
    echo $html->link("Place order", $linkMetaData);
    echo " <br/> ";
        echo $ajax->link(
            'Cancel Order',
            array('controller' => 'waiters', 'action' => 'cancelOrder', $order_token),
            array('update' => 'right_nav_container_ajax'),
            'No no no... u cancelling... Why cancel? R u sure?'
    );
}
?>

<?php
echo $form->hidden("order_token", array("value" => $order_token));
echo $form->end();
?>